import { combineReduer, createStore } from "./redux";

let initState = {
  counter: { count: 1 },
  info: { age: 25 },
};

const counterReducer = (state, action) => {
  switch (action.type) {
    case "ADD_COUNT":
      return { count: state.count + 1 };
    case "MINUS_COUNT":
      return { count: state.count - 1 };
    default:
      return state;
  }
};

const infoReducer = (state, action) => {
  switch (action.type) {
    case "ADD_AGE":
      return { age: state.age + 1 };
    case "MINUS_AGE":
      return { age: state.age - 1 };
    default:
      return state;
  }
};

const reducers = combineReduer({
  counter: counterReducer,
  info: infoReducer,
});

const store = createStore(reducers, initState);

export default store;
